import 'package:common_utils/common_utils.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter_rider/module/mine/models/truck_model.dart';
import 'package:flutter_rider/module/mine/page/message_detail.dart';
import 'package:flutter_rider/module/mine/page/message_page.dart';
import 'package:flutter_rider/module/mine/page/operator_manage_page.dart';
import 'package:flutter_rider/module/mine/page/outside_car_page.dart';
import 'package:flutter_rider/module/mine/page/outside_detail.dart';
import 'package:flutter_rider/module/mine/page/shunting_detail.dart';
import 'package:flutter_rider/module/mine/page/shunting_log.dart';
import 'package:flutter_rider/routers/i_router.dart';
import 'package:flutter_rider/module/mine/page/mine_page.dart';

class MineRouter implements IRouterProvider {
  static String minePage = '/mine';
  static String shuntimeLogPage = '/mine/shuntimeLog';
  static String shuntimeDetailPage = '/mine/shuntimeDetail';
  static String messagePage = '/mine/message';
  static String messageDetailPage = '/mine/messageDetail';
  static String outsideCarPage = '/setting/outsideCar';
  static String outsideCarDetailPage = '/setting/outsideCarDetail';
  static String operatorManagePage = '/setting/operatorManagePage';

  
  @override
  void initRouter(FluroRouter router) {
    // router.define(minePage, handler: Handler(handlerFunc: (context, params) {
    //   /// 类参数
    //   final name = context!.settings!.arguments as String;
    //   return MinePage();
    // }));
    router.define(shuntimeLogPage,
        handler: Handler(handlerFunc: (_, __) => const ShuntimeLogPage()));
    router.define(shuntimeDetailPage,
        handler: Handler(handlerFunc: (context, params) {
      /// 类参数
      final type = context?.settings?.arguments as int;
      return ShuntimeDetailPage(type);
    }));

    router.define(messagePage,
        handler: Handler(handlerFunc: (_, __) => const MessagePage()));

    router.define(messageDetailPage,
        handler: Handler(handlerFunc: (context, params) {
      /// 类参数
      final type = context?.settings?.arguments as int;
      return MessageDetailPage(type);
    }));

    router.define(outsideCarPage,
        handler: Handler(handlerFunc: (_, __) => const OutsideCarPage()));

    router.define(outsideCarDetailPage,
        handler: Handler(handlerFunc: (context, params) {
      /// 类参数
      final map = context?.settings!.arguments as Map;

      var isAddCar = map["isAddCar"] ?? false;
      var truck = map["truck"];

      return OutsideCarDetailPage(isAddCar, truck: truck);
    }));

    router.define(operatorManagePage,
        handler: Handler(handlerFunc: (_, __) => const OperatorManagePage()));

  }
}
